﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

namespace HRDexCapstoneProject.Functions.Calendar
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void txtSubmit_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=(local); Initial Catalog=HRdexDB; Integrated Security=SSPI");
            SqlDataAdapter adapter = new SqlDataAdapter();
            DataSet ds = new DataSet();
            try
            {
                conn.Open();

            }
            catch (Exception)
            {
            }

            //Add 

            SqlCommand cmd = new SqlCommand("Insert Into catEvent (EventTitle, Description, Location, DateTime, pubDateTime, Attachment) Values (@eventTitle, @desc, @loc, @datetime, @pubDateTime, @attachment )", conn);


            cmd.Parameters.Add("@eventTitle", SqlDbType.VarChar).Value = txtEventName.Text;
            cmd.Parameters.Add("@desc", SqlDbType.VarChar).Value = txtDescription.Text;
            cmd.Parameters.Add("@loc", SqlDbType.VarChar).Value = txtLocation.Text;
            cmd.Parameters.Add("@datetime", SqlDbType.Date).Value = ddl0Month.Text + "/" + ddl0Day.Text + "/" + ddl0Year.Text;
            cmd.Parameters.Add("@pubDateTime", SqlDbType.DateTime).Value = DateTime.Today;
            cmd.Parameters.Add("@attachment", SqlDbType.Binary).Value = fuAttachment.FileContent;
            //cmd.Parameters.Add("@EmployeeID", SqlDbType.VarChar).Value = txtLocation.Text;
            cmd.ExecuteNonQuery();

            conn.Close();
        }

        protected void ddl0Month_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }

    
    }
}